﻿using EA.DTO;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EA.DAO
{
    public class LikeDislikeDA:ObjectDA
    {
        public LikeDislikeDA(String connection_string)
            : base(connection_string)
        {

        }
        public Boolean InsertLike(LikeDislikeTO likeTO)
        {
            String query = "INSERT INTO LikeDislike(ProductID,CustomerID,LikeDislike) VALUES(@ProductID,@CustomerID,@LikeDislike)";
            SqlParameter[] param = new SqlParameter[3];
            param[0] = new SqlParameter("ProductID", likeTO.ProductID);
            param[1] = new SqlParameter("CustomerID",likeTO.CustomerID);
            param[2] = new SqlParameter("LikeDislike",likeTO.LikeDislike);
            return this.ExecuteNonQuery(query,param);
        }

        public DataTable GetLikeByProductIDAndCustomerId(int productId,int customerId)
        {
            String query = "SELECT * FROM LikeDislike WHERE ProductID=@productId AND CustomerID = @customerId";
            SqlParameter[] param = new SqlParameter[2];
            param[0] = new SqlParameter("@productId", productId);
            param[1] = new SqlParameter("@customerId", customerId);
            DataTable table = new DataTable();
            this.Fill(query, param, table);
            return table;
        }
    }
}
